import java.nio.channels.ServerSocketChannel;
import java.util.Scanner;
import java.util.concurrent.CountDownLatch;

public class Test3 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();

        int[][] stars = new int[n][3];

        //读取星系建筑信息
        for (int i = 0; i < n; i++) {
            stars[i][0] = scanner.nextInt();
            stars[i][1] = scanner.nextInt();
            stars[i][2] = scanner.nextInt();
        }

        int q = scanner.nextInt(); // 询问次数
        int[][] questions = new int[q][2]; // 询问坐标
        for (int i = 0; i < q; i++) {
            questions[i][0] = scanner.nextInt();
            questions[i][1] = scanner.nextInt();
        }

        for (int i = 0; i < q; i++) {
            int questionX = questions[i][0];
            int questionY = questions[i][1];
            int count = 0;
            //询问的坐标是否被影响
            for (int j = 0; j < n; j++) {
                int starX = stars[j][0];
                int starY = stars[j][1];
                int length = stars[j][2];
                if(qbxfDistance(questionX,questionY,starX,starY) <= length){
                    count++;
                }
            }
            System.out.println(count);
        }

    }

    private static int qbxfDistance(int x1,int y1,int x2,int y2){
        return Math.max(Math.abs(x1 - x2),Math.abs(y1 - y2));
    }
}
